import cv2
import pylab

lena=cv2.imread("train_image/ball.png")
img=cv2.cvtColor(lena,cv2.COLOR_BGR2RGB)
bgra=cv2.cvtColor(lena,cv2.COLOR_BGR2BGRA)
cv2.imwrite("bgra.jpg",bgra)
b,g,r,a=cv2.split(bgra)
a[:,:]=125
bgra125=cv2.merge([b,g,r,a])
cv2.imwrite("bgra125.jpg",bgra125)
img1=cv2.cvtColor(bgra125,cv2.COLOR_BGRA2RGBA)
a[:,:]=0
bgra0=cv2.merge([b,g,r,a])
cv2.imwrite("bgra0.jpg",bgra0)
img2=cv2.cvtColor(bgra0,cv2.COLOR_BGRA2RGBA)
pylab.subplot(1,3,1)
pylab.imshow(img)
pylab.subplot(1,3,2)
pylab.imshow(img1)
pylab.subplot(1,3,3)
pylab.imshow(img2)

pylab.show()